package com.zhaoqi.hr.dto.response;

import com.zhaoqi.hr.entity.JobPosting;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 岗位响应DTO
 */
public class JobPostingResponse {
    
    /**
     * 岗位ID
     */
    private Long id;
    
    /**
     * 发布者ID
     */
    private Long employerId;
    
    /**
     * 发布者名称
     */
    private String employerName;
    
    /**
     * 用工方信息
     */
    private EmployerProfileResponse employer;
    
    /**
     * 岗位标题
     */
    private String title;
    
    /**
     * 岗位描述
     */
    private String description;
    
    /**
     * 岗位类型
     */
    private JobPosting.JobType jobType;
    
    /**
     * 工作地点
     */
    private String location;
    
    /**
     * 薪资
     */
    private BigDecimal salary;
    
    /**
     * 薪资类型
     */
    private JobPosting.SalaryType salaryType;
    
    /**
     * 需要人数
     */
    private Integer requiredWorkers;
    
    /**
     * 已申请人数
     */
    private Integer appliedCount;
    
    /**
     * 工作开始时间
     */
    private LocalDateTime workStartTime;
    
    /**
     * 工作结束时间
     */
    private LocalDateTime workEndTime;
    
    /**
     * 技能要求
     */
    private String skillRequirements;
    
    /**
     * 其他要求
     */
    private String otherRequirements;
    
    /**
     * 岗位要求
     */
    private String requirements;
    
    /**
     * 福利待遇
     */
    private String benefits;
    
    /**
     * 联系人
     */
    private String contactPerson;
    
    /**
     * 联系方式
     */
    private String contactInfo;
    
    /**
     * 岗位状态
     */
    private JobPosting.JobStatus status;
    
    /**
     * 创建时间
     */
    private LocalDateTime createdAt;
    
    /**
     * 更新时间
     */
    private LocalDateTime updatedAt;
    
    /**
     * 分配的劳动者ID
     */
    private Long assignedWorkerId;
    
    /**
     * 分配的劳动者信息
     */
    private WorkerProfileResponse assignedWorker;
    
    /**
     * 分配时间
     */
    private LocalDateTime assignedAt;

    public JobPostingResponse() {}
    
    public JobPostingResponse(JobPosting jobPosting) {
        this.id = jobPosting.getId();
        this.title = jobPosting.getTitle();
        this.description = jobPosting.getDescription();
        this.jobType = jobPosting.getJobType();
        this.location = jobPosting.getLocation();
        this.salary = jobPosting.getSalary();
        this.salaryType = jobPosting.getSalaryType();
        this.requiredWorkers = jobPosting.getRequiredCount();
        this.workStartTime = jobPosting.getStartTime();
        this.workEndTime = jobPosting.getEndTime();
        this.skillRequirements = jobPosting.getSkillRequirements();
        this.otherRequirements = jobPosting.getOtherRequirements();
        this.contactInfo = jobPosting.getContactInfo();
        this.status = jobPosting.getStatus();
        this.createdAt = jobPosting.getCreatedAt();
        this.updatedAt = jobPosting.getUpdatedAt();
        this.assignedWorkerId = jobPosting.getAssignedWorkerId();
        this.assignedAt = jobPosting.getAssignedAt();
        
        if (jobPosting.getEmployer() != null) {
            this.employer = new EmployerProfileResponse(jobPosting.getEmployer());
            this.employerId = jobPosting.getEmployer().getId();
            this.employerName = jobPosting.getEmployer().getCompanyName();
        }
    }

    // Getter and Setter methods
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getEmployerId() {
        return employerId;
    }

    public void setEmployerId(Long employerId) {
        this.employerId = employerId;
    }

    public String getEmployerName() {
        return employerName;
    }

    public void setEmployerName(String employerName) {
        this.employerName = employerName;
    }

    public EmployerProfileResponse getEmployer() {
        return employer;
    }

    public void setEmployer(EmployerProfileResponse employer) {
        this.employer = employer;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public JobPosting.JobType getJobType() {
        return jobType;
    }

    public void setJobType(JobPosting.JobType jobType) {
        this.jobType = jobType;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public BigDecimal getSalary() {
        return salary;
    }

    public void setSalary(BigDecimal salary) {
        this.salary = salary;
    }

    public JobPosting.SalaryType getSalaryType() {
        return salaryType;
    }

    public void setSalaryType(JobPosting.SalaryType salaryType) {
        this.salaryType = salaryType;
    }

    public Integer getRequiredWorkers() {
        return requiredWorkers;
    }

    public void setRequiredWorkers(Integer requiredWorkers) {
        this.requiredWorkers = requiredWorkers;
    }

    public Integer getAppliedCount() {
        return appliedCount;
    }

    public void setAppliedCount(Integer appliedCount) {
        this.appliedCount = appliedCount;
    }

    public LocalDateTime getWorkStartTime() {
        return workStartTime;
    }

    public void setWorkStartTime(LocalDateTime workStartTime) {
        this.workStartTime = workStartTime;
    }

    public LocalDateTime getWorkEndTime() {
        return workEndTime;
    }

    public void setWorkEndTime(LocalDateTime workEndTime) {
        this.workEndTime = workEndTime;
    }

    public String getSkillRequirements() {
        return skillRequirements;
    }

    public void setSkillRequirements(String skillRequirements) {
        this.skillRequirements = skillRequirements;
    }

    public String getOtherRequirements() {
        return otherRequirements;
    }

    public void setOtherRequirements(String otherRequirements) {
        this.otherRequirements = otherRequirements;
    }

    public void setAssignedAt(LocalDateTime assignedAt) {
        this.assignedAt = assignedAt;
    }

    @Override
    public String toString() {
        return "JobPostingResponse{" +
                "id=" + id +
                ", employerId=" + employerId +
                ", employerName='" + employerName + '\'' +
                ", title='" + title + '\'' +
                ", description='" + description + '\'' +
                ", jobType=" + jobType +
                ", location='" + location + '\'' +
                ", salary=" + salary +
                ", salaryType=" + salaryType +
                ", requiredWorkers=" + requiredWorkers +
                ", appliedCount=" + appliedCount +
                ", workStartTime=" + workStartTime +
                ", workEndTime=" + workEndTime +
                ", status=" + status +
                ", createdAt=" + createdAt +
                ", updatedAt=" + updatedAt +
                '}';
    }
}
